
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results robust_bayarri1', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results robust_bayarri1')
    result <- sampler(100000, vy, mX, prior='robust_bayarri1', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003640000000000000,0.005560000000000000,0.001800000000000000,
0.002100000000000000,0.003090000000000000,0.004250000000000000,
0.001810000000000000,0.004290000000000000,0.001980000000000000,
0.002430000000000000,0.063289999999999999,0.003570000000000000,
0.003430000000000000,0.002090000000000000,0.001810000000000000,
0.003470000000000000,0.001580000000000000,0.001790000000000000,
0.003130000000000000,0.001620000000000000,0.001760000000000000,
0.001930000000000000,0.002170000000000000,0.001630000000000000,
0.001640000000000000,0.003900000000000000,0.001750000000000000,
0.010690000000000000,0.001570000000000000,0.004210000000000000,
0.004550000000000000,0.001620000000000000,0.002990000000000000,
0.002060000000000000,0.002000000000000000,0.006520000000000000,
0.001810000000000000,0.002810000000000000,0.001750000000000000,
0.001830000000000000,0.001860000000000000,0.042009999999999999,
0.002010000000000000,0.002000000000000000,0.001670000000000000,
0.002310000000000000,0.001870000000000000,0.001790000000000000,
0.002750000000000000,0.006850000000000000,0.002110000000000000,
0.004390000000000000,0.001830000000000000,0.011990000000000001,
0.010590000000000000,0.001460000000000000,0.002100000000000000,
0.002590000000000000,0.003040000000000000,0.010850000000000000,
0.001760000000000000,0.031460000000000002,0.002560000000000000,
0.002640000000000000,0.002420000000000000,0.008080000000000000,
0.001930000000000000,0.001840000000000000,0.001630000000000000,
0.002260000000000000,0.015429999999999999,0.001690000000000000,
0.001940000000000000,0.002410000000000000,0.002040000000000000,
0.019760000000000000,0.002160000000000000,0.003120000000000000,
0.001600000000000000,0.002030000000000000,0.001650000000000000,
0.001700000000000000,0.001870000000000000,0.002020000000000000,
0.004850000000000000,0.002210000000000000,0.180909999999999987,
0.002100000000000000,0.002830000000000000,0.023699999999999999,
0.001560000000000000,0.006010000000000000,0.003290000000000000,
0.001450000000000000,0.001820000000000000,0.004790000000000000,
0.002000000000000000,0.001630000000000000,0.015380000000000000,
0.002290000000000000,0.002730000000000000,0.010740000000000000,
0.001440000000000000,0.003790000000000000,0.001830000000000000,
0.002090000000000000,0.003940000000000000,0.004420000000000000,
0.025149999999999999,0.009169999999999999,0.004510000000000000,
0.017319999999999999,0.004380000000000000,0.002230000000000000,
0.002030000000000000,0.001670000000000000,0.003970000000000000,
0.001630000000000000,0.001900000000000000,0.001760000000000000,
0.001950000000000000,0.001620000000000000,0.007680000000000000,
0.003420000000000000,0.008710000000000001,0.001760000000000000,
0.011020000000000000,0.001990000000000000,0.002010000000000000,
0.001710000000000000,0.001950000000000000,0.009140000000000001,
0.001640000000000000,0.008990000000000000,0.005160000000000000,
0.026320000000000000,0.002710000000000000,0.001620000000000000,
0.002130000000000000,0.012239999999999999,0.012000000000000000,
0.001730000000000000,0.002360000000000000,0.001610000000000000,
0.001980000000000000,0.007939999999999999,0.008590000000000000,
0.004140000000000000,0.001560000000000000,0.001760000000000000,
0.003050000000000000,0.002780000000000000,0.945690000000000031,
0.006050000000000000,0.033509999999999998,0.001850000000000000,
0.009339999999999999,0.008980000000000000,0.015530000000000000,
0.002350000000000000,0.006400000000000000,0.007070000000000000,
0.003080000000000000,0.017059999999999999,0.002340000000000000,
0.002200000000000000,0.001490000000000000,0.002640000000000000,
0.001570000000000000,0.004110000000000000,0.001920000000000000,
0.026290000000000001,0.004310000000000000,0.002530000000000000,
0.003770000000000000,0.002800000000000000,0.007200000000000000,
0.001590000000000000,0.002780000000000000,0.743399999999999950,
0.059659999999999998,0.019720000000000001,0.007750000000000000,
0.004890000000000000,0.726260000000000017,0.002090000000000000,
0.047930000000000000,0.011360000000000000,0.003990000000000000,
0.003480000000000000,0.001940000000000000,0.001750000000000000,
0.001540000000000000,0.001770000000000000,0.001490000000000000,
0.004410000000000000,0.002000000000000000,0.002550000000000000,
0.004460000000000000,0.056759999999999998
)
, tolerance = 1e-8)
})